package solved;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	fence
*/
public class fence {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("fence.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"fence.out")));
		new fence().solve(f, out);
		out.close();
		System.exit(0);
	}
	
	private int MAX = 501;
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		int N = read(f);
		
		int[][] g = new int[MAX][MAX];
		int[] degree = new int[MAX];
		for (int i=0; i<N; i++) {
			int[] a = read(f, 2);
			g[a[0]][a[1]]++;
			g[a[1]][a[0]]++;
			degree[a[0]]++;
			degree[a[1]]++;
		}
		
		int start = MAX;
		for (int i=0; i<MAX; i++) {
			if (degree[i] == 0) continue;
			if (degree[i]%2 == 1) {
				start = i;
				break;
			}
			else {
				start = Math.min(start, i);
			}
		}
		
		ArrayList<Integer> path = new ArrayList<Integer>();
		findPath(path, g, degree, start);
		
		for (int i=path.size()-1; i>=0; i--) out.println(path.get(i));
	}
	
	private void findPath(ArrayList<Integer> path, int[][] g, int[] degree, int start) {
		if (degree[start] == 0) {
			path.add(start);
			return;
		}
		
		while (degree[start] > 0) {
			int min = MAX;
			for (int j=0; j<MAX; j++) {
				if (g[start][j] > 0) {
					min = j;
					break;
				}
			}
			
			degree[start]--;
			degree[min]--;
			g[start][min]--;
			g[min][start]--;
			
			findPath(path, g, degree, min);
		}
		
		path.add(start);
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	public int[] read(BufferedReader f, int N) throws IOException {
		String[] t = f.readLine().split(" ");
		int[] a = new int[N];
		for (int i=0; i<N; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
		return a;
	}
}
